<?php
session_start();

if (!isset($_SESSION['marks']))
{
	$_SESSION['marks'] = array(
		"1" => array("mark" => "53", "subject_id" => "1", "student_id" => "1"),
		"2" => array("mark" => "76", "subject_id" => "2", "student_id" => "1"),
		"3" => array("mark" => "15", "subject_id" => "3", "student_id" => "1"),
		"4" => array("mark" => "49", "subject_id" => "1", "student_id" => "2"),
		"5" => array("mark" => "94", "subject_id" => "1", "student_id" => "3"),
	);
	$_SESSION['marks_lastid'] = "5";
}
$marks = &$_SESSION['marks'];
$subjects = &$_SESSION['subjects'];

$student_id = $_REQUEST['student_id'];

$output = array();
foreach ($marks as $id => $row)
{
	if ($row["student_id"] == $student_id)
	{
		$output[] = array(
			"id" => $id,
			"mark" => $row["mark"],
			"subject" => $subjects[$row["subject_id"]]["subject"],
			"subject_id" => $row["subject_id"],
			"answerfile_exists" => file_exists("answerfiles/".$id.".txt")
		);
	}
}
echo json_encode(array("error" => "", "items" => $output));
?>